package com.wondream.myframework.app.common.excel.processor;

import com.google.common.collect.Lists;
import org.apache.poi.xssf.usermodel.XSSFRow;

import java.util.List;

/**
 * 行处理器策略
 */
public class RowProcessorStrategy {

    public static final List<RowProcessor> processors = Lists.newArrayList();

    static {
        processors.add(new ForeachRowProcessor());
    }

    /**
     * 获取行处理器
     */
    public static RowProcessor getRowProcessor(XSSFRow row){
        for (RowProcessor processor : processors) {
            int flag = processor.support(row);
            if (flag >= 0) {
                return processor;
            }
        }
        return DefaultRowProcessor.SINGLE.INSTANCE;
    }
}
